package com.bionic.banking.core.entity;

import java.io.Serializable;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.Date;

public class BankAccount implements Serializable {

    private Integer accountId;
    private String accountType;
    private String description;
    private BigInteger creditLine;
    private BigInteger balance;
    private BigInteger beginBalance;    
    private Integer customerId;
    private Integer currencyId;
    private Timestamp createdon;

    public BankAccount() {
    }

    public BankAccount(String type, Integer currencyCode, BigInteger balance, BigInteger creditAvailable, 
            String description, Integer customerId) {
        this.accountType = type;
        this.currencyId = currencyCode;
        this.balance = balance;
        this.beginBalance = balance;
        this.creditLine = creditAvailable;
        this.description = description;
        this.customerId = customerId;
        
         Date currDate = new java.util.Date();
         Timestamp currDateTime = new Timestamp(currDate.getTime());         
         this.createdon =currDateTime;
    }

    public Integer getAccountId() {
        return accountId;
    }

    public void setAccountId(Integer accountId) {
        this.accountId = accountId;
    }

    public String getAccountType() {
        return accountType;
    }

    public void setAccountType(String accountType) {
        this.accountType = accountType;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public BigInteger getCreditLine() {
        return creditLine;
    }

    public void setCreditLine(BigInteger creditLine) {
        this.creditLine = creditLine;
    }

    public BigInteger getBalance() {
        return balance;
    }

    public void setBalance(BigInteger balance) {
        this.balance = balance;
    }
    
    public BigInteger getBeginBalance() {
        return beginBalance;
    }

    public void setBeginBalance(BigInteger beginBalance) {
        this.beginBalance = beginBalance;
    }

    public Date getCreatedon() {
        return createdon;
    }

    public void setCreatedon(Timestamp createdon) {
        this.createdon = createdon;
    }

    public Integer getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Integer customerId) {
        this.customerId = customerId;
    }

    public Integer getCurrencyId() {
        return currencyId;
    }

    public void setCurrencyId(Integer currencyId) {
        this.currencyId = currencyId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (accountId != null ? accountId.hashCode() : 0);

        final int multiplier = 23;
        if (hash == 0) {
            int code = 133;
            code = multiplier * code + customerId.hashCode();
            hash = code;
        }
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof BankAccount)) {
            return false;
        }
        BankAccount other = (BankAccount) object;
        if (this.accountId == other.getAccountId()) {
            return true;
        }

        return true;
    }

    @Override
    public String toString() {
        return accountId.toString();
        // is " + accountType + ", balance: " + balance + " created on: " + createdon;
    }
}
